<template>
  <div style="width: 100vw;height: 100vh;overflow: hidden;display: flex" class="welcome-container">
    <div style="flex: 1" class="image-container">
      <el-image style="width: 100%;height: 100%" fit="cover"
                :src="welcomeImg" class="welcome-image"/>
    </div>
    <div class="welcome-title">
      <div style="font-size: 30px;font-weight: bold">欢迎来到职保镖</div>
      <div style="margin-top: 10px">在这里你可以进行合同审查，风险评估，交流心得。</div>
      <div style="margin-top: 5px">我们始终为您的职业之路保驾护航。</div>
    </div>
    <div class="right-card">
      <router-view v-slot="{ Component }">
        <transition name="el-fade-in-linear" mode="out-in">
          <component :is="Component" class="right-card-content"/>
        </transition>
      </router-view>
    </div>
  </div>
</template>

<script setup>
import welcomeImg from '../assets/welcome.jpg';
import { ref, onMounted } from 'vue'
import { Moon, Sunny } from '@element-plus/icons-vue'

const isDark = ref(document.documentElement.classList.contains('dark'))

const toggleDark = (value) => {
  if (value) {
    document.documentElement.classList.add('dark')
    localStorage.setItem('theme', 'dark')
  } else {
    document.documentElement.classList.remove('dark')
    localStorage.setItem('theme', 'light')
  }
}

// 在组件挂载时读取主题
onMounted(() => {
  const theme = localStorage.getItem('theme')
  if (theme === 'dark') {
    isDark.value = true
    document.documentElement.classList.add('dark')
  }
})
</script>

<style scoped>
.welcome-container {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.image-container {
  position: relative;
  padding: 20px;
}

.welcome-image {
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  border: 5px solid rgba(255, 255, 255, 0.8);
}

.right-card {
  width: 400px;
  z-index: 1;
  background-color: var(--el-bg-color);
  margin: 20px;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  border: 5px solid rgba(255, 255, 255, 0.8);
}

.right-card-content {
  padding: 20px;
}

.welcome-title {
  position: absolute;
  bottom: 50px;
  left: 50px;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  padding: 20px 30px;
  border-radius: 15px;
  transition: backdrop-filter 0.3s ease, background 0.3s ease;
}

.welcome-title:hover {
  backdrop-filter: blur(5px);
  background: rgba(0, 0, 0, 0.4);
}
</style>
